<?php 
include_once('includes.php'); 	

?>
<?php include_once('includes/header.php'); 	 ?>


<?php
//start box matchs Now playing
$sql = "select matchs.*, competition.name as cname,competition.classicon as cicon  from matchs left join competition on matchs.competition_id = competition.id  where  status=1  order by kick_off asc ";
$matchs=db_fetch_all($sql);
if(count($matchs)>0) 
{
?>	
<div class="cbox playing clearfix">
	<span class="title">Các trận đang diễn ra</span>
	<div class="content">
		<ul class="matchs">
	<?php 
	
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $match->versus; ?></strong></a>  </div>
			
		</li>
	<?php
	}
	?>
		</ul>
	</div>
</div>	
<?php
}

//start box matchs Upcoming
$sql = "select  matchs.*, competition.name as cname,competition.classicon as cicon  from matchs left join competition on matchs.competition_id = competition.id   where  status=0  order by status asc ,kick_off asc ";
$matchs=db_fetch_all($sql);
if(count($matchs)>0) 
{
?>

<div class="cbox clearfix">
	<span class="title">Lịch trực tiếp các trận sắp diễn ra</span>
	<div class="content">
		<ul class="matchs">
	<?php 
	foreach($matchs as $match)
	{
		$local_kick_off = convertTimeToLocal($match->kick_off,$match->timezone);
	?>
		<li class="<?php echo $match->cicon; ?>"> 
			<div class="cname"><?php echo $match->cname; ?></div>
			<div class="kick-off"><?php echo formatOutputDate($local_kick_off); ?></div>
			<div class="vs">	<a href="/match/<?php echo $match->id."-".clean_entities($match->versus); ?>"><strong><?php echo $match->versus; ?></strong></a>  </div>
			<div class="time-count"><?php echo remainTime($local_kick_off,'<div class="remainingTime countdown"><span class="NoDisplay">Trận đấu sẽ diễn ra sau <b class="remainingDay">%d </b> ngày <b class="remainingHour">%h </b> giờ <b class="remainingMinute">%m </b> phút <b class="remainingSecond">0</b> giây</span><span class="TimeDisplay"><span class="Text ShortText"></span><span class="Time"></span></span></div>'); ?></div>
		</li>
	<?php
	}
	?>
		</ul>
	</div>
</div>
<?php
}
?>


<?php include_once('includes/footer.php'); 	 ?>